//
//  ChatVoiceCell.swift
//  
//
//  Created by Author on 2023/3/16.
//  Copyright © 2023 Author. All rights reserved.
//

import UIKit

class ChatVoiceCell: BaseTableViewCell {
    static let kUnreadTagViewSize:CGFloat = 6
    
    static let kAnimationWidth:CGFloat = 34
    static let kAnimationHeight:CGFloat = 22
    static let kMargin:CGFloat = 8
    
   
    private lazy var playOrStopButton : UIButton = {
        let button = UIButton.init(frame: CGRect.init(x: 6.0, y: 6.0, width: 32.0, height: 32.0))
        button.setImage(UIImage(named: "playBtn"), for: .normal)
        button.backgroundColor = .clear
        button.isSelected = false
        return button
    }()
    
    private lazy var durationLabel :UILabel = {
        let label = UILabel()
        label.textColor = .white
        label.font = .systemFont(ofSize: 14, weight: .semibold)
        label.textAlignment = .right
        return label
    }()
    

    override func setupUI() {
        super.setupUI()
        wrapView.addSubview(self.playOrStopButton)
        wrapView.addSubview(durationLabel)
        self.playOrStopButton.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.centerY.equalToSuperview()
            make.width.height.equalTo(24.0)
        }
        
        
        
        self.durationLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.width.equalTo(34.0)
            make.right.equalToSuperview()
        }
        
        
    }
    
    private func updateConstraintsWithSend(){
     
        let W =  24.0 + 12.0 + 12.0 + 32.0
        wrapView.snp.updateConstraints { make in
            
            make.width.equalTo(W)
            make.trailing.equalTo(-35)
            
        }
    }
    override func updateData() {
        
        super.updateData()
        self.durationLabel.text = "9''"
        sendBubbleImgView.isHidden = false
        sendBubbleImgView.alpha = 1
        updateConstraintsWithSend()
    }
    
}
